/**
 * 
 */
package br.com.ufrn.aipetro.ga.model.persist.hibernate;

import java.util.List;

import org.hibernate.Session;

import br.com.ufrn.aipetro.ga.domain.entity.device.Device;
import br.com.ufrn.aipetro.ga.domain.entity.mesh.Mesh;
import br.com.ufrn.aipetro.ga.domain.entity.plant.Plant;
import br.com.ufrn.aipetro.ga.model.persist.hibernate.util.HibernateUtil;
import br.com.ufrn.aipetro.ga.persist.interfaces.DeviceDao;

/**
 * 
 * @author Andr�
 *
 */
public class HibernateDeviceDao extends DeviceDao {
	
	Session session;
	Class entityClass;
	
	public HibernateDeviceDao(Class entityClass) {
		this.session = HibernateUtil.getSessionFactory().getCurrentSession();
		this.entityClass = entityClass;
		basicDao = new HibernateBasicDao<Device>(session, entityClass);
	}
	
	@Override
	public List<Device> searchByMesha(Mesh mesh) {
		return (List<Device>)session.createQuery("from Device m where m.mesh = :mesh ")
				.setEntity("mesh", mesh)
				.list();
	}
}
